package com.learning.javaweb_springboot_page_query.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.learning.javaweb_springboot_page_query.entity.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {


    //通过uid查询
    @Select("SELECT id, uid FROM `order` WHERE uid = #{uid}")
    List<Order> selectByUid (int uid);



    //通过id查询
    @Select("SELECT id, uid FROM `order` WHERE id = #{id}")
    Order selectByid(Integer id);


//查询所有的订单，同时查询订单的用户
    @Select("select * from `order`")
    @Results(
            {

        @Result(column ="id", property ="id"),
        @Result(column ="uid", property ="user",
                one = @One(select ="com.learning.javaweb_springboot_page_query.mapper.UserMapper.selectById1")
                )
              }
            )

    List<Order> selectALLOrdersAndUser();
}
